import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import java.util.Vector;


public class MyXMLHandlerScene extends DefaultHandler{
    private Vector<Area> v_areas;
    private int x,y;
	private String value;
  
	public MyXMLHandlerScene (Vector<Area> v_areas)
 	{
 	   this.v_areas=v_areas;    
 	}
  
  
  public void startElement( String namespaceURI, String localName, String qName,
                                           Attributes attr ) throws SAXException 
  {
   
    
  }//startElement

  public void endElement (String namespaceURI, String localName, String rawName)
                                                             throws SAXException
  {
    if(localName.equals("name")) { 		       
        this.v_areas.add(new Area(value));
    }else if(localName.equals("x")){
		this.x = Integer.parseInt(value);		
    }else if(localName.equals("y")){		
        int pos = this.v_areas.size(); 
		this.y = Integer.parseInt(value);
        Point p = new Point(this.x, this.y);
		Area a = (Area) this.v_areas.elementAt(pos-1);
        a.addPoint(p);    }    
  }//endElement


  /*
    Los parametros que recibe es la localizacion de los carateres del elemento.
  */
  public void characters (char[] ch, int start, int end) throws SAXException
  {    
    value = new String (ch, start, end);    
    value = value.trim();         
  }//characters

}

